package model

import (
	"gorm.io/gorm"
	"time"
	"user_srv/basic/config"
)

type Equipment struct {
	Id              uint           `gorm:"column:id;type:bigint(20) UNSIGNED;primaryKey;not null;" json:"id"`
	EquipmentName   string         `gorm:"column:equipment_name;type:varchar(30);comment:器材名称;not null;" json:"equipment_name"`     // 器材名称
	EquipmentWeight string         `gorm:"column:equipment_weight;type:varchar(30);comment:器材重量;not null;" json:"equipment_weight"` // 器材重量
	EquipmentType   string         `gorm:"column:equipment_type;type:varchar(30);comment:器材分类;not null;" json:"equipment_type"`     // 器材分类
	CreatedAt       time.Time      `gorm:"column:created_at;type:datetime(3);not null;default:CURRENT_TIMESTAMP(3);" json:"created_at"`
	UpdatedAt       time.Time      `gorm:"column:updated_at;type:datetime(3);default:CURRENT_TIMESTAMP(3);" json:"updated_at"`
	DeletedAt       gorm.DeletedAt `gorm:"column:deleted_at;type:datetime(3);default:NULL;" json:"deleted_at"`
}

func (e *Equipment) TableName() string {
	return "equipment"
}
func (e *Equipment) CreateEquipment() error { //添加器材
	return config.DB.Create(&e).Error
}
func (e *Equipment) GetEquipment() error { //查询记录
	return config.DB.Where("id = ?", e.Id).Limit(1).Find(&e).Error
}
